# 启动服务的命令
echo "$DevstarHost  host.docker.internal" | tee -a /etc/hosts;

case $OS_ID in
    ubuntu|debian)
        apt-get update -y
        # 检查 SSH 是否已安装
        if ! dpkg -l | grep -q "^ii.*openssh-server"; then
            echo "SSH 未安装，将进行安装"
            apt-get install ssh -y
        else
            echo "SSH 已安装"
        fi
        # 检查 Git 是否已安装
        if ! dpkg -l | grep -q "^ii.*git"; then
            echo "Git 未安装，将进行安装"
            apt-get install git -y
        else
            echo "Git 已安装"
        fi
        
    ;;
    centos)
    #   sudo yum update -y
    #   sudo yum install -y epel-release
    #   sudo yum groupinstall -y "Development Tools"
    #   sudo yum install -y yaml-cpp yaml-cpp-devel
    ;;
    fedora)
    #   sudo dnf update -y
    #   sudo dnf group install -y "Development Tools"
    #   sudo dnf install -y yaml-cpp yaml-cpp-devel
    ;;
    *)
    exit 1
    ;;
esac

echo "PubkeyAuthentication yes\nPermitRootLogin yes\n" | tee -a /etc/ssh/sshd_config;
rm -f /etc/ssh/ssh_host_*; 
ssh-keygen -A;
mkdir -p ~/.ssh;
chmod 700 ~/.ssh;
case $OS_ID in
    ubuntu|debian)
    service ssh restart;
    ;;
    centos)
    ;;
    fedora)
    ;;
    *)
    failure "Unsupported OS: $OS_ID"
    exit 1
    ;;
esac
echo "$PUBLIC_KEY_LIST" > ~/.ssh/authorized_keys;
chmod 600 ~/.ssh/authorized_keys

